package com.lczyfz.campusinfo.modules.campusinfoeducation.web;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.lczyfz.campusinfo.common.web.BaseController;
import com.lczyfz.campusinfo.modules.campusinfoeducation.service.CampusinfoCollegeService;
import com.lczyfz.campusinfo.modules.campusinfoeducation.entity.CampusinfoCollege;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@Controller
public class CampusinfoCollegeajaxController extends BaseController{
    @Autowired    //及时获取考研学院
    private CampusinfoCollegeService campusinfoCollegeService;
    @ResponseBody
    @RequestMapping(value = "/api/campusinfoCollege/mes/get", method = RequestMethod.POST)
    public List<Map<String, Object>> allType(String schoolid ,HttpServletRequest request, HttpServletResponse response) {
        List<Map<String, Object>> mapList = Lists.newArrayList();
        CampusinfoCollege campusinfoCollege = new  CampusinfoCollege();
        campusinfoCollege.setSchoolid(schoolid);
        List< CampusinfoCollege> list =   campusinfoCollegeService.findList(campusinfoCollege);
        for (int i = 0; i < list.size(); i++) {
            CampusinfoCollege e = list.get(i);
            Map<String, Object> map = Maps.newHashMap();
            map.put("id", e.getId());
            map.put("name", e.getCollegename());
            mapList.add(map);
        }
        return mapList;
    }

}
